import tkinter as tk


def on_button_new_window(parent):
    root = parent
    new_window = tk.Toplevel(root)
    new_window.title("新窗口")
    new_window.geometry("800x600+100+100")

    # 在新窗口中添加内容
    label = tk.Label(new_window, text="这是一个新窗口")
    label.pack(pady=20)

    board_canvas = add_board(new_window, "./img/象棋棋盘3.png", 50, 160)
    # canvas_map[board_canvas] = "BOARD"
    print("board_canvas:", board_canvas)

    # 添加棋子
    start_x = 20
    start_y = 60
    cell_width = 34
    cell_height = 34
    for index, piece in enumerate(piece_init_pos):
        row = index // 16
        col = index % 16
        canvas = add_piece(new_window, piece[0],
                           start_x + col * cell_width,
                           start_y + row * cell_height, on_piece_click)
        canvas_map2[canvas] = piece[3]

    # 可以添加关闭按钮
    close_button = tk.Button(new_window, text="关闭", command=new_window.destroy)
    close_button.place(x=50, y=10)
    # close_button.pack()
